package main
{
	
	import com.darwin.darwinUI.general.DarwinFont;
	
	import flash.text.Font;

	/**
	 * 应用程序使用的字体 
	 * @author lipi
	 * 
	 */
	public class AppFont
	{
		
		public static const FONTLIBRARY:String = "FontLibrary";
		
		public static var fontClass:Class;
		
		
		public static function registerFont():void
		{
			var FontLibrary:Class = fontClass;
			if(FontLibrary == null) return;
			if(FontLibrary.DEFAULT_FONT_EMBED == DarwinFont.USE_EMBED)
			{//可能嵌入的
				Font.registerFont(FontLibrary[FontLibrary.DEFAULT_FONT]);
			}
			if(FontLibrary.AFFIRMATORY_FONT_EMBED == DarwinFont.USE_EMBED)
			{//需要嵌入的
				Font.registerFont(FontLibrary[FontLibrary.AFFIRMATORY_FONT]);
			}
			if(FontLibrary.EXTERNAL_FONT_EMBED == DarwinFont.USE_EMBED)
			{//不嵌入的
				Font.registerFont(FontLibrary[FontLibrary.EXTERNAL_FONT]);
			}
			
		}
		
		
		/**
		 * 获取默认字体（描述性的字体，有可能嵌入也有可能不嵌入的字体）
		 * @return 
		 */
		public static function get defaultFont():String
		{
			if(fontClass == null) return "宋体";
			else return fontClass.DEFAULT_FONT;
		}
		
		/**
		 * 获取默认字体是否嵌入
		 * @return 
		 * 
		 */
		public static function get defaultFontEmbed():String
		{
			if(fontClass == null) return DarwinFont.NONUSE_EMBED;
			else
			{
				return fontClass.DEFAULT_FONT_EMBED;
			}
		}
		
		
		/**
		 * 会嵌入的字体(通常是在文字库的字体，如tips等)
		 * @return 
		 */
		public static function get affirmatoryFont():String
		{
			if(fontClass == null) return "Tahoma";
			else return fontClass.AFFIRMATORY_FONT;
		}
		
		/**
		 * affirmatoryFont 返回affirmatoryFont 的嵌入的类别
		 * @return 
		 */
		public static function get affirmatoryFontEmbed():String
		{
			if(fontClass == null) return DarwinFont.NONUSE_EMBED;
			else return fontClass.AFFIRMATORY_FONT_EMBED;
		}
		
		
		/**
		 * 外部的文字使的字体，一般不嵌入的文字（如姓名等）
		 * @return 
		 */
		public static function get externalFont():String
		{
			if(fontClass == null) return "Tahoma";
			else return fontClass.EXTERNAL_FONT;
		}
		
		/**
		 * 返回externalFont 的嵌入的类别
		 * @return 
		 */
		public static function get externalFontEmbed():String
		{
			if(fontClass == null) return DarwinFont.NONUSE_EMBED;
			else return fontClass.EXTERNAL_FONT_EMBED;
		}
		
		
		/**
		 * 
		 * 创建AffirmatoryFont字体
		 * 
		 */
		public static function createAffirmatoryFont(size:uint = 11, bold:Boolean = false, italic:Boolean = false, 
													 underline:Boolean = false, align:String="left", leading:int = 0,
													 langSize:Object = null):DarwinFont
		{
			
			return new DarwinFont(AppFont.affirmatoryFont,size,bold,italic,underline,AppFont.affirmatoryFontEmbed,align,leading);
		}
		
		
		/**
		 * 
		 * 创建ExternalFont
		 * 
		 */
		public static function creatExternalFont(size:uint = 11, bold:Boolean = false, italic:Boolean = false, 
													 underline:Boolean = false, align:String="left", leading:int = 0,
													 langSize:Object = null):DarwinFont
		{
			
			return new DarwinFont(AppFont.externalFont,size,bold,italic,underline,AppFont.externalFontEmbed,align,leading);
		}
		
		/**
		 * 创建DefaultFont
		 * 
		 */
		public static function createDefaultFont(size:uint = 11, bold:Boolean = false, italic:Boolean = false, 
													 underline:Boolean = false, align:String="left", leading:int = 0,
													 langSize:Object = null):DarwinFont
		{
			
			return new DarwinFont(AppFont.defaultFont,size,bold,italic,underline,AppFont.defaultFontEmbed,align,leading);
		}
		
	}
}